<?php 
session_start();
if (!isset($_SESSION['Username'])) {
                header("location:login.php");
        }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrator Delete Accounts</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="scripts/rand_password.js"></script>
<?php include('includes/path.php'); ?>

</head>

<body class="oneColFixCtrHdr">

<div id="container">
<?php include( 'includes/header.php' ); ?>
<?php include( 'includes/menu.php' ); ?>
<?php include ('includes/status.php'); ?>

  <div id="mainContent">
     <?php
	// This file inserts the following
	// variables: USER, PASS, DB
	include('db.php');

    ?>
      <!-- <p><a href="admin.php">Back to Admin Page</a></p> -->
      <form action="" method="POST" enctype="multipart/form-data" name="changePasswords" target="_parent">
          <?php
          
          

            $TABLE = "Users";
            $TABLE2 = "Users";

            $CON = mysql_connect( $HOST, $USER, $PASS );

            if (!$CON){
                die('Could not connect: ' . mysql_error());
            }

            mysql_select_db( $DB );
            
            
            
            $rowNum = (isset($_POST['numberOfRows']) ? htmlspecialchars($_POST['numberOfRows']) : '');
            
            while($rowNum>0){
                
		$rowNum --;        
		$tmp = (isset($_POST[$rowNum]) ? htmlspecialchars($_POST[$rowNum]) : '');
		if(Empty($tmp)){
                }
		else {
                    $SQL = "DELETE from Users where login ='$tmp'";
                    //echo $SQL;
                    mysql_query($SQL);
                    
                }                      
            }

          ?>
      </form>
        
        
        
        
<?php        
        echo '<div  align ="center">
	<form action="" method="POST" enctype="multipart/form-data" name="changePasswords" target="_parent">
	<table style="width: 50%; border: 5p09x #aba groove;" align="center">';
        
        //mysql_close($CON);
        
        $TABLE2 = "Users";
        $ROW_NUMBER = 0;
        

        if (!$CON)
          {
                  die('Could not connect: ' . mysql_error());
          }
        
        mysql_select_db( $DB );
        $QRY = 'SELECT * FROM ' . $TABLE2;
        

        echo '<table style="width: 100%; border: 5px #aba groove;">';   
        echo '<tr><td  style="height:25px;"></td></tr>';
        echo '<tr style="background-color: #77C48E;"><th colspan=4>Delete Accounts</th></tr>';
        echo '<tr style="background-color: #D6B376;"><th style="text-align: center; width:50px;">Del</th><th style="text-align: center; width: 500px;">Login Name</th></tr>';
        
        $RESULT = mysql_query($QRY);
        
	while($ROW = mysql_fetch_array($RESULT))
        {
            
                $rowNumString = (string)($ROW_NUMBER);
                $passVar = "passName".$rowNumString;
                $passValueVar = "passValue".$rowNumString;
                $confirmVar ="confirmName".$rowNumString;
                $confirmValueVar = "confirmValue".$rowNumString;
                $rowEmail = "email".$rowNumString;            
            
            
                echo '<tr style="background-color: #';
                if ( $ROW_NUMBER % 2 ){ echo 'FFF;"'; }
                else { echo 'DEDEDE;"'; }
                echo '><td><input type="checkbox" name="'.$ROW_NUMBER.'" value="'.$ROW['login'].'"/></td><td>' . $ROW['login'] . '</td>
                    <input type="hidden" name="'.$rowEmail.'" value="'.$ROW['login'].'"></tr>';
        $ROW_NUMBER++;
        }
        
        
        echo '<tr><td  style="height:25px;"></td></tr>';
        echo '<tr><td style="text-align: right;"></td>
            <td style="text-align: center;"><input type="submit" value="Delete Selected Users"></td></tr>';
        echo '<input type="hidden" name="numberOfRows" value="'.$ROW_NUMBER.'">';
        echo '</table>';
        
        echo '</table></form></div>';
        
        
        
        
        mysql_close($CON);
    
?>
  <!-- end #mainContent --></div>
<?php include('includes/footer.php'); ?>
<!-- end #container --></div>
</body>
</html>
